package com.qidian.buy.content.controller;

import com.qidian.buy.content.service.IContentCategoryService;
import com.qidian.buy.entity.ContentCategory;
import com.qidian.buy.util.pojo.BuyResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

/**
 * <p>
 * 内容分类 前端控制器
 * </p>
 *
 * @author 戴着假发的程序员
 * @since 2023-05-18
 */
@RestController
@RequestMapping("/buy/contentCategory")
@CrossOrigin
public class ContentCategoryController {
    @Autowired
    private IContentCategoryService contentCategoryService;

    @GetMapping("/delete")
    public BuyResult delete(Long id){
        return  contentCategoryService.deleteContentCat(id);
    }

    @PostMapping("/saveOrUpdate")
    public BuyResult<ContentCategory> saveOrUpdate(ContentCategory cat){
        return contentCategoryService.saveOrUpdateContentCat(cat);
    }
    @GetMapping("/queryByParentId")
    public BuyResult<ContentCategory> queryByParentId(Long parentId){
        return contentCategoryService.queryByParentId(parentId);
    };
}
